
using UnityEditor;
using UnityEngine;


namespace XFGameFramework.MissionSystem
{
    public class MissionTypePopWindow : PopupWindowContent
    {

        private string type;

        private ConfigsWindow window;
        private MissionConfigData data;

        private bool isOpen = false;

        public MissionTypePopWindow(ConfigsWindow window, MissionConfigData data)
        {
            this.window = window;
            this.data = data;
        }

        public override void OnGUI(Rect rect)
        {
            if (!isOpen) return;

            GUILayout.BeginArea(rect);

            EditorGUI.BeginChangeCheck();

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("请输入类型名称");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();

            GUILayout.Space(10);

            type = EditorGUILayout.DelayedTextField("Type", type);
            
            GUILayout.Space(10);

            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck()) 
            {
                if (string.IsNullOrEmpty(type))
                    return;

                //this.data.type = type;
                EditorUtility.SetDirty(window.currentMissionConfig);
                this.editorWindow.Close();
            }

            GUILayout.EndArea();
        }

        public override Vector2 GetWindowSize()
        {
            //设置弹窗的尺寸
            return new Vector2(300, 80);
        }


        public override void OnOpen()
        {
            base.OnOpen();
            isOpen = true;
        }

        public override void OnClose()
        {
            base.OnClose();
            isOpen = false;
        }

    }

}

